/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ace.game.level;

import ace.game.Path;
import ace.game.entity.enemy.Enemy;
import ace.game.entity.enemy.EnemyFactory;
import ace.game.entity.pickup.Pickup;
import ace.system.xml.XmlNode;
import java.util.Vector;

/**
 *
 * @author Hallucinogen
 */
public class EnemyWaves {
	private EnemyWaves() {
		mEnemies = new Vector();
	}

	public EnemyWaves(XmlNode XML) {
		this();

		//For each child
		for (int i = 0; i < XML.getChildren().size(); i++) {
			//Get child
			XmlNode Child = (XmlNode)XML.getChildren().elementAt(i);
            int pickupData = -1;

			//Check name
			if (Child.getNodeName().equals("enemy")) {
				//Prepare variable
				int data	= Integer.parseInt(Child.getAttribute("data"));
				int startAt	= Integer.parseInt(Child.getAttribute("start-at"));
				Path path	= null;
				for (int j = 0, m = Child.getChildren().size(); j < m; ++j) {
					XmlNode GrandChild	= (XmlNode)Child.getChildren().elementAt(j);
					String GCTag		= GrandChild.getNodeName();
					if (GCTag.equals("path")) {
						path = new Path(((XmlNode)GrandChild.getChildren().firstElement()).getNodeValue());
					} else if (GCTag.equals("pickup")) {
						pickupData = Integer.parseInt(GrandChild.getAttribute("data"));
					}
				}
				mEnemies.addElement(new Enemy(EnemyFactory.instance().getEnemyData(data), path, startAt, pickupData));
			}
		}
	}

    public Vector getEnemies() { return mEnemies; }

	private Vector mEnemies;
}
